<!DOCTYPE html>
<html>

<head>
    <title>我要办事</title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">

    <meta name="description" content="">

    <link rel="stylesheet" href="dist/lib/weui.css">
    <link rel="stylesheet" href="dist/css/build.css">
    <link rel="stylesheet" href="dist/css/jquery-weui.css">

    <style>
        body {
            background: #f5f5f5
        }

        .weui-cells.weui-cells_form {
            background: #fff;
            border-bottom: 1px solid #EDEDED;
            /*-moz-box-shadow: 2px 2px 5px #333333;*/
            /*-webkit-box-shadow: 0px 2px 15px #eee;*/
            /*box-shadow: 0px 2px 15px #eee;*/
        }

        .weui-uploader__input-box {
            margin-top: 5px;
        }

        .img-ico {
            width: 30px;
            height: 30px;
            /* background-color: aquamarine; */
            display: block;
            padding-left: 10px;
            border-left: 1px solid #eeeeee;
            float: left;
        }

        .img-ico img {
            width: 30px;
            height: 30px;
        }

        .weui-cell {
            padding-left: 0px;
            padding: 0px;

        }


        label {
            height: 30px;
            width: 120px;
            line-height: 30px;
            display: inline-block;
            padding-left: 8px;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            /* float: left; */
        }

        .connt span {
            position: relative;
            /* height: 50px; */
            padding-top: 12px;
            padding-bottom: 7px;
            vertical-align: middle;
            display: inline-table;
            width: 47%;

            /* border-right: 1px solid #eeeeee; */

            padding-left: 15px;
            /* overflow: hidden; */
            /*超出部分隐藏*/
            /* white-space: nowrap; */
            /*不换行*/
            /* text-overflow: ellipsis; */
            /*超出部分文字以...显示*/

        }

        .connt span:nth-child(2n) {
            border: none;
            padding-left: 0px;


        }

        .connt span:nth-child(2n+1) .img-ico {
            border: none;
            padding-left: 0px;


        }

        label:after {
            content: " ";
            border-bottom: 1px solid #eeeeee;
            width: 100%;
            /* display: inline-flex; */
            position: absolute;
            left: 10px;
            bottom: 0px;
            /* display: inline-block; */
        }

        .weui-cells {
            margin-top: 15px;
        }
    </style>
</head>

<body>
<!-- 1 -->
<div id="connt">
    <div class="weui-cells weui-cells_form" v-for="item in items">
        <div class="weui-cells__title">{{item.name}}</div>
        <div class="weui-cell">
            <div class="weui-cell__bd connt">
                    <span v-for="itemson in item.data" @click="openAddWork(itemson.id,itemson.name)">
                        <b></b>
                        <i class="img-ico"><img :src="itemson.logoUrl" alt=""></i>
                        <label class="label">{{itemson.name}}</label>
                        
                    </span>

                <!-- <span class="two"> <i class="img-ico two"><img src="1" alt=""></i><label>我要办事</label></span> -->
            </div>
        </div>
    </div>

    <!-- <div v-for="item in items">

        <div>{{item.name}}</div>

        <div v-for="itemson in item.data">  

            <div>{{itemson.decText}}</div>

        </div>
    </div> -->

</div>
<!-- end -->


<!-- <div class="weui-msg__extra-area">
    <div class="weui-footer">
        <p class="weui-footer__links">
            <a href="javascript:void(0);" class="weui-footer__link">中共东莞市律师行业委员会</a>
        </p>
        <p class="weui-footer__text">Copyright © 2008-2020</p>
    </div>
</div> -->

<script src="dist/lib/jquery-2.1.4.js"></script>
<script src="dist/lib/fastclick.js"></script>
<script>
    $(function () {
        FastClick.attach(document.body);
    });
</script>

<script src="dist/js/jquery-weui.js"></script>
<script src="dist/lib/vue.min.js"></script>
<script src="dist/lib/http.js"></script>
<script src="dist/lib/imgUp.js"></script>
<script src="dist/lib/jquery.cookie.js"></script>

<script>


    $http.getUserSignIn(false, 'onlinework.html');
    console.log($http.getUserSignIn());

    //vue 模板替换
    var news = new Vue({
        el: '#connt',
        data: {
            items: [] //列表信息流数据
        }
    });
    getData()

    function openAddWork(id, str) {
        $.cookie('AddWork', $http.getCookieArray(id, str));
        window.location.href = 'online_add_work.html?id=' + id + '&title=' + str;
    }

    function getData() {
        $http.post($http.getWork()).then(function (data) {
            if (data.success == true) {
                news.items = news.items.concat(juheshuzhu(data.data, 'dictId'));
                console.log(juheshuzhu(data.data, 'dictId'))

            } else {
                window.location.href = 'index.html';
            }

        }, function (err) {
            console.log(err);
            return err;
        });
    }

    function juheshuzhu(arr, dictId = '') {
        var map = {},
            dest = [];
        for (var i = 0; i < arr.length; i++) {
            var ai = arr[i];
            if (!map[ai[dictId]]) {
                dest.push({
                    dictId: ai[dictId],
                    name: ai.dictName,
                    data: [ai]
                });
                map[ai[dictId]] = ai;
            } else {
                for (var j = 0; j < dest.length; j++) {
                    var dj = dest[j];
                    if (dj[dictId] == ai[dictId]) {
                        dj.data.push(ai);
                        break;
                    }
                }
            }
        }
        return dest;
    }
</script>

</body>

</html>